//
//  CoreDataRoutine.h
//  BallistaTimeline
//
//  Created by s.zalozniy on 3/27/13.
//  Copyright 2013 Mozi Development. All rights reserved.
//

#import <CoreData/CoreData.h>

#import "CDCategories.h"
#import "CDProducts.h"
#import "CDImages.h"
#import "CDCollections.h"


@interface CoreDataRoutines : NSObject {
    NSManagedObjectModel *managedObjectModel;
    NSManagedObjectContext *managedObjectContext;	    
    NSPersistentStoreCoordinator *persistentStoreCoordinator;
}

@property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;

+(CoreDataRoutines *) sharedInstance;

-(void) saveManagedObjectContext:(NSManagedObjectContext *)context;
-(void) saveMainContext;
-(void) dropDataBase;

-(void) addObserverForManagedObjectContext:(NSManagedObjectContext *)context;
-(void) removeObserverForManagedObjectContext:(NSManagedObjectContext *)context;

-(void) startSynchronization;

-(CDCategories *) categoryWithIdent:(NSNumber *)ident;
-(CDImages *) imageWithUrl:(NSString *)url;
-(CDProducts *) productWithIdent:(NSNumber *)ident;
-(CDCollections *) collectionWithIdent:(NSNumber *)ident;

-(NSArray *) categories;

@end